// ignore_for_file: prefer_const_constructors, file_names, prefer_interpolation_to_compose_strings, unused_element, use_super_parameters

import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../home/index.dart';

class DetailView extends StatelessWidget {
  const DetailView({Key? key}) : super(key: key);
  _bulidBackListTileRow(Map? val){
    return val == null || val["id"] == null
    ? Container( )
    : ListTile(
      title: Text(
        "传值 id = " + val["id"].toString()
      ),
      subtitle: Text('Get.back(result: {"success": true}'),
      onTap: () => Get.back(result: {"success": true}),
    );
  }
  @override
  Widget build(BuildContext context) {
    Map? details = Get.arguments;
    Map? parameters = Get.parameters;
    return Scaffold(
      appBar: AppBar(
        title: Text("DetailView详情页"),
        centerTitle: true,
        backgroundColor: Colors.green[300],
      ),
      body: ListView(
        children: [
          ListTile(
            title: Text("DetailView导航返回"),
            subtitle: Text('Get.back()'),
            onTap: () => Get.back(),
          ),
          _bulidBackListTileRow(details),
          _bulidBackListTileRow(parameters),
          TextButton(onPressed: ()=>Get.offAll(() => HomeView()), child: Text("主页(Get.offAll 清除前面所有路由)",style: TextStyle(fontSize: 20)),)
        ],
      ),
    );
  }
}